package cn.hdu.liang.ccio;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Scanner;

import static cn.hdu.liang.ccio.FileUtil.open;

class FileUtil {
    public static void open(String fileName, IOConsumer<FileInputStream> consumer) {
        try(FileInputStream in = new FileInputStream(fileName)) {
            consumer.accept(in);
        } catch(IOException ex) {
            throw new UncheckedIOException(ex);
        }
    }
}


public class Exercise3 {
    public static void main(String[] args) {
        open(args[0], fileInputStream -> {
            Scanner file = new Scanner(fileInputStream);
            while(file.hasNextLine()) {
                System.out.println(file.nextLine());
            }
        });
    }
}
